#include <stdio.h>
#include <string.h>
#include <stdbool.h>

bool Cmp(char *ptr,char c)
{
    while(*ptr != '\0')
    {
        if(*ptr == c)
            return true;
        ptr++;
    }
    return false;
}

char* Mytok(char *str,char *ptr)
{
    static char *dest = NULL;
    if(str == NULL)
        str = dest;
    if(str == NULL)
        return NULL;
    while(*str != '\0')
    {
        if(Cmp(ptr,*str))
        {
            str++;
        }
        else
            break;
    }

    if(str == NULL)
        return NULL;
    char *end = str;
    while(*end != '\0')
    {
        if(Cmp(ptr,*end))
            break;
        else
            end++;
    }
    if(*end == '\0')
    {
        dest = NULL;
    }
    else
    {
        *end = '\0';
        dest = end + 1;
    }
    return str;

    
}

int main()
{
    char s[] = "zhangsan,lisi.wangwu.";
    char p[] = ",.";
    char *c = Mytok(s,p);
    while(c != NULL)
    {
        printf("%s\n",c);
        c = Mytok(NULL,p);
    }
    return 0;
}